// 管理商品数据相关逻辑
export default {
  namespaced: true,
  state() {
    return {
      goods: [
        { name: "手机", price: 9999 },
        { name: "手机1", price: 999.9 },
        { name: "手机2", price: 99.99 },
        { name: "手机3", price: 9.999 },
      ],
    };
  },
  getters: {
    //相当于组件中的computed、拿到state数据，处理得到新数据
    filterGoods(state) {
      return state.goods.filter((item) => item.price > 600);
    },
  },
  mutations: {
    addGoodsMut(state, newGoods) {
      state.goods.push(newGoods);
    },
  },
};
